//
//  NYSearchHistoryCell.m
//  NiuWaJiaoYu
//
//  Created by MinLison on 2018/1/8.
//  Copyright © 2018年 niuwaketang. All rights reserved.
//

#import "NYSearchHistoryCell.h"
#import "NYSearchHistoryModel.h"

@interface NYSearchHistoryCell ()

@property (nonatomic, strong) UIImageView *historyImgView;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UIView *lineView;

@end

@implementation NYSearchHistoryCell

//MARK :Nimbus
- (BOOL)shouldUpdateCellWithObject:(NYSearchHistoryModel *)object {
    
    if (![object isKindOfClass:[NYSearchHistoryModel class]]) {
        return false;
    }
    [self updateContentWithModel:object];
    return true;
}
+ (CGFloat)heightForObject:(id)object identifier:(NSString *)identifier atIndexPath:(NSIndexPath *)indexPath tableView:(UITableView *)tableView {

    return 41.f;
}

- (void)setupView {
    [super setupView];
    
    [self.contentView addSubview:self.historyImgView];
    [self.contentView addSubview:self.nameLabel];
    [self.contentView addSubview:self.lineView];

    [self.historyImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.top.mas_equalTo(15);
        make.width.height.mas_equalTo(15);
    }];

    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.historyImgView.mas_right).offset(10);
        make.right.equalTo(self.contentView).offset(-15);
        make.top.bottom.equalTo(self.contentView);
    }];
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.right.equalTo(self.contentView);
        make.bottom.equalTo(self.contentView);
        make.height.mas_equalTo(1);
    }];

}
- (void)updateContent {
    [super updateContent];
    
}
#pragma mark - Target Methods

#pragma mark - Public Methods

#pragma mark - Private Method

- (void)updateContentWithModel:(NYSearchHistoryModel *)model {
    
    self.nameLabel.text = model.historyString;
}

#pragma mark - Setter Getter Methods
- (UIImageView *)historyImgView {
    if (!_historyImgView) {
        _historyImgView = [[UIImageView alloc] init];
        _historyImgView.image = [UIImage deng_dai];//UIImageMake(@"search_history_mark");
    }
    return _historyImgView;
}
- (UILabel *)nameLabel {
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.font = UIFontMake(14.f);
        _nameLabel.textColor = UIColorMakeWithHex(@"#666666");
    }
    return _nameLabel;
}
- (UIView *)lineView {
    if (!_lineView) {
        _lineView = [[UIView alloc] initWithFrame:CGRectZero];
        [_lineView setBackgroundColor:UIColorMakeWithHex(@"#E1E1E1")];
    }
    return _lineView;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
